package com.zl.tesseract.scanner.loop;

import java.util.concurrent.BlockingQueue;
import java.util.concurrent.LinkedBlockingDeque;
import java.util.concurrent.ThreadPoolExecutor;
import java.util.concurrent.TimeUnit;

/**
 * 线程池
 */
public class MyThreadPool extends  ThreadPoolExecutor{


    private static MyThreadPool pool;

    private MyThreadPool(int corePoolSize, int maximumPoolSize, long keepAliveTime, TimeUnit unit, BlockingQueue<Runnable> workQueue) {
        super(corePoolSize, maximumPoolSize, keepAliveTime, unit, workQueue);
    }


   public static MyThreadPool getInstance(){
        if (pool ==null){
            synchronized (MyThreadPool.class){
                if (pool == null){
                    pool = new MyThreadPool(10,40,10,TimeUnit.SECONDS,
                            new LinkedBlockingDeque<Runnable>(128));
                }
            }
        }
        return pool;
    }



}
